const arr = [1,4,5,6,7,3,9,2,5,7,8,9];

/**
 * 冒泡排序
 */
 function bubbleSort(array) {
  for (let index = 0; index < array.length; index++) {
    for (let j = 0;  j< array.length; j++) {
      if(array[j] > array[j+1]) {
        let temp = array[j];
        array[j] = array[j+1];
        array[j+1] = temp;
      }
    }
  }
  console.log('冒泡排序',array)
  return array;
}

// bubbleSort(arr)

/**
 * 插入排序
 */

function insertionSort(arr) {
  let len = arr.length;
  if (len <= 1) {
      return arr;
  }
  for (let i = 0; i < arr.length; i++) {
    let j = i-1, val = arr[i];
      for(; j >= 0; j--) {
        if(arr[j] > val) {
          arr[j+1] = arr[j]
        }else {
          break;
        }
      }
      arr[j+1] = val
  }
  console.log('插入排序' ,arr);
  return arr;
}
// insertionSort(arr)

/**
 * 归并排序
 */
function Sort(params) {
  
}
